<template>
    <div class="dealer">
        <div style="position:fixed;width:calc(100%);z-index: 999;box-shadow: 0px 0px 10px #ccc;top:90px ">
            <Spin fix v-if="spinShow">
                <Icon type="ios-loading" size=60 class="demo-spin-icon-load"></Icon>
                <div>请稍后...</div>
            </Spin>
        <Row class="btns">
            <Col class="channelClick">
                <!-- 当前按钮是否展示0（新增，修改）表示展示、1表示不展示（查看页面），-->
                <Button type="primary" @click="staging()" v-if="this.typeCode == '0'"   icon="ios-create-outline">暂存</Button>
                <Button type="primary" @click="save()" v-if="this.typeCode != '1'  " icon="ios-create-outline"   >保存</Button>
                <Button type="primary" @click="submit()" v-if="this.typeCode != '1'" icon="ios-create-outline"   >提交</Button>

               <!-- <Button type="success" @click="save2()" v-if="this.typeCode2 == '2'" icon="ios-create-outline">保存</Button>
                <Button type="success" @click="submit2()" v-if="this.typeCode2 == '2'" icon="ios-create-outline">提交</Button>-->

                <!--<Button type="primary" @click="blacklist()" v-if="this.typeCode == '1'" icon="ios-create-outline">黑名单申请</Button>-->
                <Button type="primary" @click="back()" icon="ios-create-outline" >返回</Button>
            </Col>
        </Row>
        <ul class="channel_text channel_title">
            <li v-for="(item,index) in tabsType" :key="index" :class="{active:curTab===index}" @click="toggle(index)">
                <p></p>
               <span>{{item.value}}</span>
            </li>
        </ul>
        </div>
        <div class="specific_field" style="padding-top: 160px;">
            <div v-show="curTab===0">
                <!--基本信息-->
                <basic-info ref="basicInfo" :channelType="channelType"></basic-info>

            </div>
            <div v-show="curTab===1">
                <!--收款账号信息-->
                <account-info ref="accountInfo"></account-info>
            </div>
            <!--<div v-show="curTab===2">
                &lt;!&ndash;附件&ndash;&gt;
                <attachment-info ref="attachmentInfo"></attachment-info>
            </div>-->
            <div v-if="curTab===2">
                <!--附件-->
                <file-operation  :uploadParam="uploadParam" :isInt="canUpload"  :path="path"  :readOnly="readOnly" ></file-operation>
            </div>
        </div>

    </div>
</template>
<script>
import "_p/afs-apply/assets/css/channelBase.css";
import BasicInfo from "./basic-info/directCarDealerBasicInfo.vue";
import AccountInfo from "./payment-account/directCarDealerAccountInfo.vue";
import AttachmentInfo from "./attachment-info/attachmentInfo.vue";
import FileOperation from "_p/basic/pages/image/upload-file/fileOperation.vue";

export default {
    name:"DirectCarDealerDealerMain",
    props: {

    },
    data(){
        return{

            //所属合作商id
            belongChannelId:"",
            //附件部分
            uploadParam: {
                busiNo: "",
                belongNo: "",
                busiType: "",
                busiData: {}
            },
            canUpload:true,
            path:"apply",
            readOnly:true,



            spinShow: false,
            //默认隐藏父页面
            channelManage:true,
            channelId:"",
            /*默认从基本信息开始*/
            typeCode:0,
            typeCode2:0,
            curTab:0,
            type:0,
            //渠道归属
            channelType:"",
            tabsType:[
                {
                    value:"基本信息"
                },
                {
                    value:"收款账号信息"
                },
                
                {
                    value:"附件"
                },
            ],
            remarkForm:{
                remark:"",
            },
            remarkFormValidate:{
                remark:[
                ]
            },
        }
    },
    components:{
        //注入子组件
        BasicInfo,
        AccountInfo,
       // AttachmentInfo,
        FileOperation
    },
    created(){
    },
    methods:{
        init() {

            console.log(this.afs.getPageParams(this).channelId,"带过来的车商id")

            if(this.afs.getPageParams(this).type=="1"){
                //新增操作
                this.basicInfoView(this.afs.getPageParams(this).infoView);
            }else if(this.afs.getPageParams(this).type=="0"||this.afs.getPageParams(this).type=="2"){
                //表示修改或查看
                this.basicInfoView(this.afs.getPageParams(this).infoView);
                this.channel(this.afs.getPageParams(this).channelId);
                this.bottonView(this.afs.getPageParams(this).bottonView);
                this.changeTypeCode(this.afs.getPageParams(this).type);
                this.$refs.basicInfo.getOldChannelId2(this.afs.getPageParams(this).oldChannelId);
                this.belongChannelId = this.afs.getPageParams(this).oldChannelId;
            }
            this.typeCode2=this.afs.getPageParams(this).type;

            if(this.typeCode != '1'){
                this.readOnly = false;
            }
        },
        changeTypeCode(v){
            this.$refs.basicInfo.changeTypeCode(v);
        },
        channel(v){
            //渠道基本信息获取
            this.$refs.basicInfo.getChannelInfo(v);
            //收款账号信息获取
            this.$refs.accountInfo.getAccountInfo(v);
            //授权区域
          //  this.$refs.basicInfo.getMainAreaList(v);
            //主营品牌
            this.$refs.basicInfo.getBaseTreeList(v);
            //授权车型
            this.$refs.basicInfo.getCarsTreeList(v);
            this.channelId =v;
        },
        basicInfoView(v){
            //授权区域初始化
         //   this.$refs.basicInfo.getMainAreaList();
            //主营品牌树初始化
            this.$refs.basicInfo.getBaseTreeList();
            //授权车型树初始化
            this.$refs.basicInfo.getCarsTreeList();
            //基础信息
            this.$refs.basicInfo.readOnlyInfo(v);
            //收款账号信息
            this.$refs.accountInfo.readOnlyInfo(v);
        },
        toggle(index){
            this.curTab=index;
        },
        submit(){
            if(this.curTab=="0"){
                //基本信息
                this.$refs.basicInfo.basicSubmit();
            }else if(this.curTab=="1"|| this.curTab=="2"){
                //收款账号信息
                let channelId = this.channelId;
                if(channelId==""||channelId == undefined) {
                    this.$Message.error("请先保存基本信息");
                    return;
                }
                this.$refs.accountInfo.invoiceSubmit();
            }
        },
        /*submit2(){
            if(this.curTab=="0"){
                //基本信息
                this.$refs.basicInfo.updateSubmit();
                console.log("更新后提交审核")
            }else if(this.curTab=="1"|| this.curTab=="2"){
                //收款账号信息
                let channelId = this.channelId;
                if(channelId==""||channelId == undefined) {
                    this.$Message.error("请先保存基本信息");
                    return;
                }
                this.$refs.accountInfo.invoiceSave();
            }
        },*/
        getAccountInfo(v){
            //基本信息提交后收款账号信息获取
            this.$refs.accountInfo.getAccountInfo(v);
        },


        save(){
            if(this.curTab=="0"){
                //基本信息
                this.$refs.basicInfo.basicSave();
            }else if(this.curTab=="1"|| this.curTab=="2"){
                //收款账号信息
                let channelId = this.channelId;
                if(channelId==""||channelId == undefined) {
                    this.$Message.error("请先保存基本信息");
                    return;
                }
                this.$refs.accountInfo.invoiceSave();
            }
        },
        staging(){
            if(this.curTab=="0"){
                //基本信息
                this.$refs.basicInfo.stagingSave();
            }else if(this.curTab=="1"|| this.curTab=="2"){
                //收款账号信息
                let channelId = this.channelId;
                if(channelId==""||channelId == undefined) {
                    this.$Message.error("请先保存基本信息");
                    return;
                }
                this.$refs.accountInfo.invoiceSave();
            }
        },
        blacklist(){
            //黑名单
            this.$refs.basicInfo.blackChannel();
        },
        back(){
            //关闭页面
            this.afs.closeTab(this);
        },
        setchannelId(v){
            //获取子组件基本信息页面保存的渠道id
            this.channelId=v;
            if(v){
                this.initGetFilterParams();
            }
        },
        useBasicSubmitToCase(){
            //账户页面调用基本信息页面的提交方法
            this.$refs.basicInfo.basicSubmit();
        },
        //点击编辑查看按钮展示不通的按钮
        bottonView(flag){
            this.typeCode=flag;
        },
        initGetFilterParams() {
            this.uploadParam.busiNo = this.channelId;
            this.uploadParam.belongNo =  this.belongChannelId;
            this.uploadParam.busiData = {};
            this.uploadParam.busiType = "carDealerApply";
        },
    },
    mounted() {
        this.init();
        if(this.channelId){
            this.initGetFilterParams();
        }
    }
}
</script>

<style scoped>
    .dealer .btns{
        background-color: white;
        padding: 20px 0 0 0;
    }
    .dealer .btns button{
        margin-right: 50px;
    }

    .dealer .channelClick{
        display: flex;
        flex-flow: row;
        justify-content: flex-end;
        align-items: center;
    }
    .dealer .ivu-spin-fix{
        background-color: hsla(0,0%,100%,.5)
    }

    .dealer .demo-spin-col{
        height: 100px;
        position: relative;
        border: 1px solid #eee;
    }
    .dealer .demo-spin-icon-load{
        animation: ani-demo-spin 1s linear infinite;
    }
</style>
